import { defineStore } from "pinia";
import { fenStore } from "./fenStore";
export const mainStore = defineStore("main", {
  state: () => {
    return {
      birthday: "2022-02-02",
      count: 0,
      phone: "13233313333",
    };
  },
  getters: {
    phoneHidden(state) {
      console.log("PhoneHidden被调用了");
      return state.phone.substring(0, 3) + "****" + state.phone.substring(7);
    },
    // 用this就不用箭头函数 指向问题
    phoneHidden2() {
      console.log("PhoneHidden被调用了2");
      return this.phone.substring(0, 3) + "****" + this.phone.substring(7);
    },
  },
  actions: {
    // 不要用箭头函数 箭头指向最外层
    changeMyState() {
      this.count = this.count + 5;
    },
    getList() {
      console.log("======fenStore().list>>>>====", fenStore().list);
    },
  },
});
